<?php

namespace app\api\controller\app;

use app\admin\model\Deviceslot;
use app\admin\model\Org;
use app\admin\model\Shop;
use app\admin\model\Shopcharge;
use app\admin\model\Shoporder;
use app\admin\model\Shopstaff;
use app\admin\model\Userbalance;
use app\admin\model\Usercoupon;
use app\admin\model\Usertuan;
use app\admin\model\Userweixin;
use app\common\controller\Api;
use app\common\library\Ems;
use app\common\library\Sms;
use EasyWeChat\Factory;
use fast\Random;
use think\Config;
use think\Validate;

/**
 * 会员接口
 */
class Device extends Api
{
    protected $noNeedLogin = ['info'];
    protected $noNeedRight = '*';

    protected $app = null;

    public function info()
    {

        $device_id = $this->request->param('device_id');
        $deviceModel = new \app\admin\model\Device();
        $device = $deviceModel->where('device_id',$device_id)->find();
        $device['isShow'] = false;
        $this->success('',$device);
    }

    public function skuList()
    {

        $device_id = $this->request->param('device_id');
        $keyword = $this->request->param('keyword');
        $deviceSlotModel = new Deviceslot();
        $where = array();
        $where['name'] = ['like', '%' . trim($keyword) . '%'];
        $where['device_id'] = $device_id;
        $list = $deviceSlotModel->with(['good'])->where($where)->where('Deviceslot.status',1)->group('good_id')->select();

        foreach ($list as $key=>$val){
            $list[$key]['good']['cover'] = cdnurl($val['good']['cover'],true);
        }
        $this->success('',$list);
    }
}
